﻿<%@ Page Title="首页" Language="C#" MasterPageFile="~/ASP/HomeSite.Master" AutoEventWireup="true"
    CodeBehind="Home.aspx.cs" Inherits="Agricultural_Sales.ASP.Home" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style>
            .home-container {
                max-width: 1200px;
                margin: 0 auto;
                padding: 20px;
            }

            .search-section {
                background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
                padding: 30px;
                border-radius: 15px;
                margin-bottom: 30px;
                box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
                position: relative;
                overflow: hidden;
            }

            .search-section::before {
                content: '';
                position: absolute;
                top: -50%;
                right: -50%;
                width: 100%;
                height: 100%;
                background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="20" fill="%23ffffff" opacity="0.1">🌾🍎🥕🌽</text></svg>') repeat;
                animation: float 20s infinite linear;
            }

            @keyframes float {
                0% {
                    transform: translateX(-100px);
                }

                100% {
                    transform: translateX(100px);
                }
            }

            .search-title {
                color: white;
                font-size: 32px;
                font-weight: 700;
                text-align: center;
                margin-bottom: 25px;
                text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
                position: relative;
                z-index: 1;
            }

            .search-controls {
                display: flex;
                gap: 15px;
                align-items: center;
                justify-content: center;
                flex-wrap: wrap;
                position: relative;
                z-index: 1;
            }

            .search-label {
                color: white;
                font-weight: 600;
                font-size: 16px;
                text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
            }

            .search-dropdown {
                padding: 12px 15px;
                border: none;
                border-radius: 10px;
                font-size: 16px;
                background: white;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
                min-width: 150px;
                transition: all 0.3s ease;
            }

            .search-dropdown:focus {
                outline: none;
                box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
                transform: translateY(-2px);
            }

            .search-textbox {
                padding: 12px 15px;
                border: none;
                border-radius: 10px;
                font-size: 16px;
                background: white;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
                min-width: 200px;
                transition: all 0.3s ease;
            }

            .search-textbox:focus {
                outline: none;
                box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
                transform: translateY(-2px);
            }

            .search-textbox::placeholder {
                color: #999;
                font-style: italic;
            }

            .search-btn {
                background: linear-gradient(45deg, #2E7D32, #4CAF50);
                color: white;
                border: none;
                padding: 12px 25px;
                border-radius: 10px;
                font-size: 16px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.3s ease;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .search-btn:hover {
                background: linear-gradient(45deg, #1B5E20, #2E7D32);
                transform: translateY(-3px);
                box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
            }

            .reset-btn {
                background: linear-gradient(45deg, #FF9800, #FFB74D);
                color: white;
                border: none;
                padding: 12px 25px;
                border-radius: 10px;
                font-size: 16px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.3s ease;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .reset-btn:hover {
                background: linear-gradient(45deg, #F57C00, #FF9800);
                transform: translateY(-3px);
                box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
            }

            .products-section {
                margin-top: 30px;
            }

            .section-title {
                font-size: 28px;
                font-weight: 700;
                color: #2c3e50;
                margin-bottom: 20px;
                text-align: center;
                position: relative;
            }

            .section-title::before {
                content: '🌱';
                position: absolute;
                left: 50%;
                transform: translateX(-50%);
                top: -40px;
                font-size: 32px;
            }

            .section-title::after {
                content: '';
                position: absolute;
                bottom: -8px;
                left: 50%;
                transform: translateX(-50%);
                width: 80px;
                height: 4px;
                background: linear-gradient(90deg, #4CAF50, #45a049, #FF9800);
                border-radius: 2px;
            }

            .products-grid {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
                gap: 30px;
                margin-top: 50px;
            }

            .product-card {
                background: white;
                border-radius: 20px;
                overflow: hidden;
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
                transition: all 0.4s ease;
                border: 2px solid transparent;
                position: relative;
            }

            .product-card::before {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                height: 4px;
                background: linear-gradient(90deg, #4CAF50, #FF9800, #2196F3);
                opacity: 0;
                transition: opacity 0.3s ease;
            }

            .product-card:hover {
                transform: translateY(-10px) scale(1.02);
                box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
                border-color: #4CAF50;
            }

            .product-card:hover::before {
                opacity: 1;
            }

            .product-image {
                width: 100%;
                height: 220px;
                object-fit: cover;
                transition: transform 0.4s ease;
            }

            .product-card:hover .product-image {
                transform: scale(1.1);
            }

            .product-info {
                padding: 25px;
            }

            .product-name {
                font-size: 20px;
                font-weight: 700;
                color: #2c3e50;
                margin-bottom: 10px;
                line-height: 1.3;
            }

            .product-origin {
                color: #7f8c8d;
                font-size: 14px;
                margin-bottom: 12px;
                font-weight: 500;
            }

            .product-price {
                font-size: 24px;
                font-weight: 800;
                color: #e74c3c;
                margin-bottom: 12px;
                text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
            }

            .product-inventory {
                color: #27ae60;
                font-size: 14px;
                margin-bottom: 20px;
                font-weight: 600;
            }

            .product-actions {
                display: flex;
                gap: 10px;
            }

            .detail-btn {
                flex: 1;
                background: linear-gradient(45deg, #3498db, #5dade2);
                color: white;
                border: none;
                padding: 12px 20px;
                border-radius: 10px;
                font-size: 15px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.3s ease;
                text-decoration: none;
                text-align: center;
                display: inline-block;
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .detail-btn:hover {
                background: linear-gradient(45deg, #2980b9, #3498db);
                transform: translateY(-2px);
                text-decoration: none;
                color: white;
                box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
            }

            .no-products {
                text-align: center;
                padding: 80px 20px;
                color: #7f8c8d;
                font-size: 18px;
                background: white;
                border-radius: 20px;
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            }

            .no-products-icon {
                font-size: 80px;
                margin-bottom: 25px;
                opacity: 0.6;
            }

            .no-products h3 {
                color: #2c3e50;
                font-size: 24px;
                margin-bottom: 15px;
            }

            @media (max-width: 768px) {
                .search-controls {
                    flex-direction: column;
                    align-items: stretch;
                    gap: 12px;
                }

                .search-dropdown,
                .search-textbox,
                .search-btn,
                .reset-btn {
                    width: 100%;
                    min-width: auto;
                }

                .products-grid {
                    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
                    gap: 20px;
                }

                .search-title {
                    font-size: 24px;
                }
            }
        </style>
    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <div class="home-container">
            <!-- 搜索筛选区域 -->
            <div class="search-section">
                <h2 class="search-title">🌱 发现优质农产品 🍎</h2>
                <div class="search-controls">
                    <span class="search-label">选择分类：</span>
                    <asp:DropDownList ID="ddlCategory" runat="server" CssClass="search-dropdown">
                        <asp:ListItem Value="0" Text="所有分类" Selected="True"></asp:ListItem>
                    </asp:DropDownList>

                    <span class="search-label">商品名称：</span>
                    <asp:TextBox ID="txtSearch" runat="server" CssClass="search-textbox" placeholder="请输入商品名称..." />

                    <asp:Button ID="btnSearch" runat="server" Text="🔍 搜索" CssClass="search-btn"
                        OnClick="btnSearch_Click" />
                    <asp:Button ID="btnReset" runat="server" Text="🔄 重置" CssClass="reset-btn"
                        OnClick="btnReset_Click" />
                </div>
            </div>

            <!-- 商品展示区域 -->
            <div class="products-section">
                <h3 class="section-title">精选商品</h3>

                <asp:Repeater ID="rptProducts" runat="server">
                    <HeaderTemplate>
                        <div class="products-grid">
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div class="product-card">
                            <asp:Image ID="imgProduct" runat="server" ImageUrl='<%# GetImageUrl(Eval("ImageUrl")) %>'
                                AlternateText='<%# Eval("Name") %>' CssClass="product-image" />
                            <div class="product-info">
                                <h4 class="product-name">
                                    <%# Eval("Name") %>
                                </h4>
                                <p class="product-origin">📍 产地：<%# Eval("Origin") %>
                                </p>
                                <div class="product-price">¥<%# Eval("Price", "{0:F2}" ) %> / <%# Eval("Unit") %>
                                </div>
                                <p class="product-inventory">📦 库存：<%# Eval("Inventory") %>
                                        <%# Eval("Unit") %>
                                </p>
                                <div class="product-actions">
                                    <asp:HyperLink ID="lnkDetail" runat="server"
                                        NavigateUrl='<%# "ProductDetail.aspx?id=" + Eval("ProductId") %>'
                                        CssClass="detail-btn">
                                        📋 查看详情
                                    </asp:HyperLink>
                                </div>
                            </div>
                        </div>
                    </ItemTemplate>
                    <FooterTemplate>
            </div>
            </FooterTemplate>
            </asp:Repeater>

            <!-- 无商品提示 -->
            <asp:Panel ID="pnlNoProducts" runat="server" Visible="false" CssClass="no-products">
                <div class="no-products-icon">🌾</div>
                <h3>暂无商品</h3>
                <p>当前条件下没有找到商品，请尝试调整搜索条件或重置筛选。</p>
            </asp:Panel>
        </div>
        </div>
    </asp:Content>